/*
 *
 *  * Copyright (c) 2020-2023, Lykan (jiashuomeng@gmail.com).
 *  * <p>
 *  * Licensed under the Apache License, Version 2.0 (the "License");
 *  * you may not use this file except in compliance with the License.
 *  * You may obtain a copy of the License at
 *  * <p>
 *  *     http://www.apache.org/licenses/LICENSE-2.0
 *  * <p>
 *  * Unless required by applicable law or agreed to in writing, software
 *  * distributed under the License is distributed on an "AS IS" BASIS,
 *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  * See the License for the specific language governing permissions and
 *  * limitations under the License.
 *
 */
package cn.kstry.framework.core.component.strategy;

import cn.kstry.framework.core.bpmn.FlowElement;
import cn.kstry.framework.core.bus.ContextStoryBus;

/**
 * 节点执行策略
 *
 * @author lykan
 */
public interface PeekStrategy {

    /**
     * 是否使用当前策略
     *
     * @return true：使用
     */
    boolean match(FlowElement flowElement);

    /**
     * 是否跳过当前 FlowElement
     *
     * @param flowElement flowElement
     * @param contextStoryBus contextStoryBus
     * @return true：需要
     */
    default boolean skip(FlowElement flowElement, ContextStoryBus contextStoryBus) {
        return false;
    }

    /**
     * 判断每一个出度子项是否需要被探出
     *
     * @param flowElement flowElement
     * @param contextStoryBus contextStoryBus
     * @return true：需要
     */
    boolean needPeek(FlowElement flowElement, ContextStoryBus contextStoryBus);

    /**
     * 允许出度为空
     *
     * @return true：允许
     */
    default boolean allowOutingEmpty(FlowElement flowElement) {
        return false;
    }
}